<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MTB CAT1 Peripheral driver library: Low Power Callbacks</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="IFXCYP_one-line.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">MTB CAT1 Peripheral driver library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__group__syspm__functions__callback.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Low Power Callbacks<div class="ingroups"><a class="el" href="group__group__syspm.html">SysPm        (System Power Management)</a> &raquo; <a class="el" href="group__group__syspm__functions.html">Functions</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga0d58b00c8dc764a6371590f70e2f73c7"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__syspm__functions__callback.html#ga0d58b00c8dc764a6371590f70e2f73c7">Cy_SysPm_RegisterCallback</a> (<a class="el" href="structcy__stc__syspm__callback__t.html">cy_stc_syspm_callback_t</a> *handler)</td></tr>
<tr class="memdesc:ga0d58b00c8dc764a6371590f70e2f73c7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Registers a new syspm callback.  <a href="#ga0d58b00c8dc764a6371590f70e2f73c7">More...</a><br /></td></tr>
<tr class="separator:ga0d58b00c8dc764a6371590f70e2f73c7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab7b9b923fceff2f37a6b8288253b0e82"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__syspm__functions__callback.html#gab7b9b923fceff2f37a6b8288253b0e82">Cy_SysPm_UnregisterCallback</a> (<a class="el" href="structcy__stc__syspm__callback__t.html">cy_stc_syspm_callback_t</a> const *handler)</td></tr>
<tr class="memdesc:gab7b9b923fceff2f37a6b8288253b0e82"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function unregisters a callback.  <a href="#gab7b9b923fceff2f37a6b8288253b0e82">More...</a><br /></td></tr>
<tr class="separator:gab7b9b923fceff2f37a6b8288253b0e82"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga95462119281ba8dec6b313f85dd752b0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__syspm__data__enumerates.html#ga601b1cb722cb091133caf33d8ab235ca">cy_en_syspm_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__syspm__functions__callback.html#ga95462119281ba8dec6b313f85dd752b0">Cy_SysPm_ExecuteCallback</a> (<a class="el" href="group__group__syspm__data__enumerates.html#ga8c2960c0164ead1cfa86e7d6846b6ff0">cy_en_syspm_callback_type_t</a> type, <a class="el" href="group__group__syspm__data__enumerates.html#gae06cd8869fe61d709ad6145ca9f3cd63">cy_en_syspm_callback_mode_t</a> <a class="el" href="group__group__ipc__bt__data__structures.html#ga37e90f5e3bd99fac2021fb3a326607d4">mode</a>)</td></tr>
<tr class="memdesc:ga95462119281ba8dec6b313f85dd752b0"><td class="mdescLeft">&#160;</td><td class="mdescRight">The function executes all registered callbacks with provided type and mode.  <a href="#ga95462119281ba8dec6b313f85dd752b0">More...</a><br /></td></tr>
<tr class="separator:ga95462119281ba8dec6b313f85dd752b0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa6983aaa09683543722f57bbe76b9695"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structcy__stc__syspm__callback__t.html">cy_stc_syspm_callback_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__syspm__functions__callback.html#gaa6983aaa09683543722f57bbe76b9695">Cy_SysPm_GetFailedCallback</a> (<a class="el" href="group__group__syspm__data__enumerates.html#ga8c2960c0164ead1cfa86e7d6846b6ff0">cy_en_syspm_callback_type_t</a> type)</td></tr>
<tr class="memdesc:gaa6983aaa09683543722f57bbe76b9695"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reads the result of the callback execution after the power mode functions execution.  <a href="#gaa6983aaa09683543722f57bbe76b9695">More...</a><br /></td></tr>
<tr class="separator:gaa6983aaa09683543722f57bbe76b9695"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga0d58b00c8dc764a6371590f70e2f73c7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga0d58b00c8dc764a6371590f70e2f73c7">&#9670;&nbsp;</a></span>Cy_SysPm_RegisterCallback()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Cy_SysPm_RegisterCallback </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structcy__stc__syspm__callback__t.html">cy_stc_syspm_callback_t</a> *&#160;</td>
          <td class="paramname"><em>handler</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Registers a new syspm callback. </p>
<p>A callback is a function called after an event in the driver or middleware module has occurred. The handler callback API will be executed if the specific event occurs. SysPm callbacks are called when changing power modes. See <a class="el" href="structcy__stc__syspm__callback__t.html">cy_stc_syspm_callback_t</a>.</p>
<dl class="section note"><dt>Note</dt><dd>The registered callbacks are executed in two orders, based on callback mode <a class="el" href="group__group__syspm__data__enumerates.html#gae06cd8869fe61d709ad6145ca9f3cd63">cy_en_syspm_callback_mode_t</a>. For modes CY_SYSPM_CHECK_READY and CY_SYSPM_BEFORE_TRANSITION, the order is same order as callbacks were registered. For modes CY_SYSPM_AFTER_TRANSITION and CY_SYSPM_CHECK_FAIL, the order is reverse as the order callbacks were registered.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">handler</td><td>The address of the syspm callback structure. See <a class="el" href="structcy__stc__syspm__callback__t.html">cy_stc_syspm_callback_t</a>.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>True if a callback was registered.</li>
<li>False if a callback was not registered.</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd>Do not modify the registered structure in run-time. </dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>After being registered, the SysPm callback structures must be allocated during power mode transition.</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"><span class="comment">/* Scenario: There is a need to have three callbacks for the CPU Deep Sleep </span></div><div class="line"><span class="comment">*  mode. DeepSleepFunc1 and DeepSleepFunc2 callback function skip </span></div><div class="line"><span class="comment">*  CY_SYSPM_BEFORE_TRANSITION mode.</span></div><div class="line"><span class="comment">*  DeepSleepFunc3 executes all four modes. </span></div><div class="line"><span class="comment">*  Note that for the multi-CPU devices the another CPU must be in CPU </span></div><div class="line"><span class="comment">*  Deep Sleep power mode. </span></div><div class="line"><span class="comment">*/</span></div><div class="line"></div><div class="line"><span class="comment">/******************************************************************************</span></div><div class="line"><span class="comment">*  Callback prototypes</span></div><div class="line"><span class="comment">******************************************************************************/</span></div><div class="line"><a class="code" href="group__group__syspm__data__enumerates.html#ga601b1cb722cb091133caf33d8ab235ca">cy_en_syspm_status_t</a> DeepSleepFunc1(<a class="code" href="structcy__stc__syspm__callback__params__t.html">cy_stc_syspm_callback_params_t</a> *callbackParams, <a class="code" href="group__group__syspm__data__enumerates.html#gae06cd8869fe61d709ad6145ca9f3cd63">cy_en_syspm_callback_mode_t</a> mode);</div><div class="line"><a class="code" href="group__group__syspm__data__enumerates.html#ga601b1cb722cb091133caf33d8ab235ca">cy_en_syspm_status_t</a> DeepSleepFunc2(<a class="code" href="structcy__stc__syspm__callback__params__t.html">cy_stc_syspm_callback_params_t</a> *callbackParams, <a class="code" href="group__group__syspm__data__enumerates.html#gae06cd8869fe61d709ad6145ca9f3cd63">cy_en_syspm_callback_mode_t</a> mode);</div><div class="line"><a class="code" href="group__group__syspm__data__enumerates.html#ga601b1cb722cb091133caf33d8ab235ca">cy_en_syspm_status_t</a> DeepSleepFunc3(<a class="code" href="structcy__stc__syspm__callback__params__t.html">cy_stc_syspm_callback_params_t</a> *callbackParams, <a class="code" href="group__group__syspm__data__enumerates.html#gae06cd8869fe61d709ad6145ca9f3cd63">cy_en_syspm_callback_mode_t</a> mode);</div></div><!-- fragment --><div class="fragment"><div class="line"><span class="comment">/******************************************************************************</span></div><div class="line"><span class="comment">*  Parameter structures for callback functions</span></div><div class="line"><span class="comment">******************************************************************************/</span></div><div class="line"><a class="code" href="structcy__stc__syspm__callback__params__t.html">cy_stc_syspm_callback_params_t</a> deepSleepParam1 = </div><div class="line">{</div><div class="line">    NULL,</div><div class="line">    NULL</div><div class="line">};</div><div class="line"></div><div class="line"><a class="code" href="structcy__stc__syspm__callback__params__t.html">cy_stc_syspm_callback_params_t</a> deepSleepParam2 = </div><div class="line">{</div><div class="line">    &amp;HW1_address,</div><div class="line">    &amp;context</div><div class="line">};</div><div class="line"></div><div class="line"><a class="code" href="structcy__stc__syspm__callback__params__t.html">cy_stc_syspm_callback_params_t</a> deepSleepParam3 = </div><div class="line">{</div><div class="line">    &amp;HW2_address,</div><div class="line">    NULL</div><div class="line">};</div></div><!-- fragment --><div class="fragment"><div class="line"><span class="comment">/******************************************************************************</span></div><div class="line"><span class="comment">*  Callbacks structures</span></div><div class="line"><span class="comment">******************************************************************************/</span></div><div class="line"><a class="code" href="structcy__stc__syspm__callback__t.html">cy_stc_syspm_callback_t</a> myDeepSleep1 = </div><div class="line">{</div><div class="line">    &amp;DeepSleepFunc1, </div><div class="line">    <a class="code" href="group__group__syspm__data__enumerates.html#gga8c2960c0164ead1cfa86e7d6846b6ff0abc51d74deff0ceea4304b01b2d57bd9d">CY_SYSPM_DEEPSLEEP</a>,</div><div class="line">    <a class="code" href="group__group__syspm__skip__callback__modes.html#ga77a2dc7326bb7e6cf893dc7b258b3a42">CY_SYSPM_SKIP_BEFORE_TRANSITION</a>,</div><div class="line">    &amp;deepSleepParam1,</div><div class="line">    NULL,</div><div class="line">    NULL,</div><div class="line">    0</div><div class="line">};</div><div class="line"></div><div class="line"><a class="code" href="structcy__stc__syspm__callback__t.html">cy_stc_syspm_callback_t</a> myDeepSleep2 = </div><div class="line">{</div><div class="line">    &amp;DeepSleepFunc2, </div><div class="line">    <a class="code" href="group__group__syspm__data__enumerates.html#gga8c2960c0164ead1cfa86e7d6846b6ff0abc51d74deff0ceea4304b01b2d57bd9d">CY_SYSPM_DEEPSLEEP</a>,</div><div class="line">    <a class="code" href="group__group__syspm__skip__callback__modes.html#ga77a2dc7326bb7e6cf893dc7b258b3a42">CY_SYSPM_SKIP_BEFORE_TRANSITION</a>,</div><div class="line">    &amp;deepSleepParam2,</div><div class="line">    NULL,</div><div class="line">    NULL,</div><div class="line">    0</div><div class="line">};</div><div class="line"></div><div class="line"><a class="code" href="structcy__stc__syspm__callback__t.html">cy_stc_syspm_callback_t</a> myDeepSleep3 = </div><div class="line">{</div><div class="line">    &amp;DeepSleepFunc3, </div><div class="line">    <a class="code" href="group__group__syspm__data__enumerates.html#gga8c2960c0164ead1cfa86e7d6846b6ff0abc51d74deff0ceea4304b01b2d57bd9d">CY_SYSPM_DEEPSLEEP</a>,</div><div class="line">    0U,</div><div class="line">    &amp;deepSleepParam3,</div><div class="line">    NULL,</div><div class="line">    NULL,</div><div class="line">    0</div><div class="line">};</div><div class="line">    </div></div><!-- fragment --><div class="fragment"><div class="line"><span class="comment">/******************************************************************************</span></div><div class="line"><span class="comment">*  DeepSleepFunc1 implementation</span></div><div class="line"><span class="comment">******************************************************************************/</span></div><div class="line"><a class="code" href="group__group__syspm__data__enumerates.html#ga601b1cb722cb091133caf33d8ab235ca">cy_en_syspm_status_t</a> DeepSleepFunc1(<a class="code" href="structcy__stc__syspm__callback__params__t.html">cy_stc_syspm_callback_params_t</a> *callbackParams, <a class="code" href="group__group__syspm__data__enumerates.html#gae06cd8869fe61d709ad6145ca9f3cd63">cy_en_syspm_callback_mode_t</a> mode)</div><div class="line">{</div><div class="line">    <a class="code" href="group__group__syspm__data__enumerates.html#ga601b1cb722cb091133caf33d8ab235ca">cy_en_syspm_status_t</a> retVal = <a class="code" href="group__group__syspm__data__enumerates.html#gga601b1cb722cb091133caf33d8ab235caa5e406c6cb40fdf6663df0208737d4f11">CY_SYSPM_FAIL</a>;</div><div class="line">    </div><div class="line">    </div><div class="line">    <span class="keywordflow">if</span> (callbackParams != NULL)</div><div class="line">    {</div><div class="line">        <span class="comment">/* In this use case we do not need to use HW address or context</span></div><div class="line"><span class="comment">        * So, need to add code to some switch case with callbackParams to avoid </span></div><div class="line"><span class="comment">        * compiler warnings</span></div><div class="line"><span class="comment">        */</span></div><div class="line">    }</div><div class="line">    </div><div class="line">    <span class="keywordflow">switch</span>(mode)</div><div class="line">    {</div><div class="line">        <span class="comment">/* In this case ensure that firmware/hardware is ready for CPU</span></div><div class="line"><span class="comment">        *  Deep Sleep mode */</span></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__syspm__data__enumerates.html#ggae06cd8869fe61d709ad6145ca9f3cd63ab7ec706d80b347433d0063f2a8115784">CY_SYSPM_CHECK_READY</a>:</div><div class="line">            <span class="keywordflow">if</span>(<span class="keyword">true</span><span class="comment">/* system is ready */</span>)</div><div class="line">            {</div><div class="line">                <span class="comment">/* Process the &quot;check ready&quot; condition */</span></div><div class="line">                retVal = <a class="code" href="group__group__syspm__data__enumerates.html#gga601b1cb722cb091133caf33d8ab235caaf00d22f1ee891a8a56f8bbf58132e775">CY_SYSPM_SUCCESS</a>;</div><div class="line">            }</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        </div><div class="line">        <span class="comment">/* One of the registered callback that was executed after this callback </span></div><div class="line"><span class="comment">        *  returned CY_SYSPM_FAIL, need to revert changes (if any) performed in </span></div><div class="line"><span class="comment">        *  the CY_SYSPM_CHECK_READY case.</span></div><div class="line"><span class="comment">        */</span></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__syspm__data__enumerates.html#ggae06cd8869fe61d709ad6145ca9f3cd63a96acf2d0ae5537798228d5fba0fecd17">CY_SYSPM_CHECK_FAIL</a>:</div><div class="line">            {</div><div class="line">                <span class="comment">/* Revert changes done in the CY_SYSPM_CHECK_READY case */</span></div><div class="line">                retVal = <a class="code" href="group__group__syspm__data__enumerates.html#gga601b1cb722cb091133caf33d8ab235caaf00d22f1ee891a8a56f8bbf58132e775">CY_SYSPM_SUCCESS</a>;</div><div class="line">            }</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">            </div><div class="line">        <span class="comment">/* This case will be skipped during callbacks execution */</span></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__syspm__data__enumerates.html#ggae06cd8869fe61d709ad6145ca9f3cd63a7d302375276b3b5f250a8208c999b558">CY_SYSPM_BEFORE_TRANSITION</a>:</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">            </div><div class="line">        <span class="comment">/* This case is executed after wakeup from system Deep Sleep */</span></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__syspm__data__enumerates.html#ggae06cd8869fe61d709ad6145ca9f3cd63aafd1db1f7f86ac7bbd18d59b78af5693">CY_SYSPM_AFTER_TRANSITION</a>:</div><div class="line">            {</div><div class="line">                <span class="comment">/* Perform actions, if required, after wakeup from the  </span></div><div class="line"><span class="comment">                *  system Deep Sleep mode */</span></div><div class="line">                retVal = <a class="code" href="group__group__syspm__data__enumerates.html#gga601b1cb722cb091133caf33d8ab235caaf00d22f1ee891a8a56f8bbf58132e775">CY_SYSPM_SUCCESS</a>;</div><div class="line">            }</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        </div><div class="line">        <span class="keywordflow">default</span>:</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">    }</div><div class="line">    </div><div class="line">    <span class="keywordflow">return</span> (retVal);</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">/******************************************************************************</span></div><div class="line"><span class="comment">*  DeepSleepFunc2 implementation</span></div><div class="line"><span class="comment">******************************************************************************/</span></div><div class="line"><a class="code" href="group__group__syspm__data__enumerates.html#ga601b1cb722cb091133caf33d8ab235ca">cy_en_syspm_status_t</a> DeepSleepFunc2(<a class="code" href="structcy__stc__syspm__callback__params__t.html">cy_stc_syspm_callback_params_t</a> *callbackParams, <a class="code" href="group__group__syspm__data__enumerates.html#gae06cd8869fe61d709ad6145ca9f3cd63">cy_en_syspm_callback_mode_t</a> mode)</div><div class="line">{</div><div class="line">    <a class="code" href="struct_cy_s_c_b___type.html">CySCB_Type</a> *hwBase = (<a class="code" href="struct_cy_s_c_b___type.html">CySCB_Type</a> *) callbackParams-&gt;<a class="code" href="structcy__stc__syspm__callback__params__t.html#a56076e99358e2b7c99681312108b09af">base</a>;</div><div class="line">    <a class="code" href="structcy__stc__scb__spi__context__t.html">cy_stc_scb_spi_context_t</a> *context = (<a class="code" href="structcy__stc__scb__spi__context__t.html">cy_stc_scb_spi_context_t</a> *) callbackParams-&gt;<a class="code" href="structcy__stc__syspm__callback__params__t.html#abac771f244791efe23d4964a40bbf8c8">context</a>;</div><div class="line">    </div><div class="line">    <a class="code" href="group__group__syspm__data__enumerates.html#ga601b1cb722cb091133caf33d8ab235ca">cy_en_syspm_status_t</a> retVal = <a class="code" href="group__group__syspm__data__enumerates.html#gga601b1cb722cb091133caf33d8ab235caa5e406c6cb40fdf6663df0208737d4f11">CY_SYSPM_FAIL</a>;</div><div class="line"></div><div class="line">    <span class="keywordflow">switch</span>(mode)</div><div class="line">    {</div><div class="line">        <span class="comment">/* Check is the HW1 ready to enter CPU Deep Sleep */</span></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__syspm__data__enumerates.html#ggae06cd8869fe61d709ad6145ca9f3cd63ab7ec706d80b347433d0063f2a8115784">CY_SYSPM_CHECK_READY</a>:</div><div class="line">        {</div><div class="line">            <span class="comment">/* ... */</span></div><div class="line">            <span class="keywordflow">if</span> (0UL == (<a class="code" href="group__group__scb__spi__macros__xfer__status.html#gab024f7d6ed7cbaa36c80c904a6179de7">CY_SCB_SPI_TRANSFER_ACTIVE</a> &amp; <a class="code" href="group__group__scb__spi__high__level__functions.html#ga95069817e25be749ae989e5d7131f8d0">Cy_SCB_SPI_GetTransferStatus</a>(hwBase, context)))</div><div class="line">            {</div><div class="line">                <span class="comment">/* There are no active actions so we can enter CPU Deep Sleep */</span></div><div class="line">                retVal = <a class="code" href="group__group__syspm__data__enumerates.html#gga601b1cb722cb091133caf33d8ab235caaf00d22f1ee891a8a56f8bbf58132e775">CY_SYSPM_SUCCESS</a>;</div><div class="line">            }</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="keywordflow">default</span>:</div><div class="line">            retVal = <a class="code" href="group__group__syspm__data__enumerates.html#gga601b1cb722cb091133caf33d8ab235caa5e406c6cb40fdf6663df0208737d4f11">CY_SYSPM_FAIL</a>;</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">    }</div><div class="line">    </div><div class="line">    <span class="keywordflow">return</span> (retVal);</div><div class="line">}</div><div class="line"></div><div class="line">    </div><div class="line"><span class="comment">/******************************************************************************</span></div><div class="line"><span class="comment">*  DeepSleepFunc3 implementation</span></div><div class="line"><span class="comment">******************************************************************************/</span></div><div class="line"><a class="code" href="group__group__syspm__data__enumerates.html#ga601b1cb722cb091133caf33d8ab235ca">cy_en_syspm_status_t</a> DeepSleepFunc3(<a class="code" href="structcy__stc__syspm__callback__params__t.html">cy_stc_syspm_callback_params_t</a> *callbackParams, <a class="code" href="group__group__syspm__data__enumerates.html#gae06cd8869fe61d709ad6145ca9f3cd63">cy_en_syspm_callback_mode_t</a> mode)</div><div class="line">{</div><div class="line">    <a class="code" href="struct_cy_s_c_b___type.html">CySCB_Type</a> *hwBase = (<a class="code" href="struct_cy_s_c_b___type.html">CySCB_Type</a> *) callbackParams-&gt;<a class="code" href="structcy__stc__syspm__callback__params__t.html#a56076e99358e2b7c99681312108b09af">base</a>;</div><div class="line"></div><div class="line">    <a class="code" href="group__group__syspm__data__enumerates.html#ga601b1cb722cb091133caf33d8ab235ca">cy_en_syspm_status_t</a> retVal = <a class="code" href="group__group__syspm__data__enumerates.html#gga601b1cb722cb091133caf33d8ab235caa5e406c6cb40fdf6663df0208737d4f11">CY_SYSPM_FAIL</a>;</div><div class="line"></div><div class="line">    <span class="keywordflow">switch</span>(mode)</div><div class="line">    {</div><div class="line">        <span class="comment">/* Check is the HW2 ready to enter into CPU Deep Sleep */</span></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__syspm__data__enumerates.html#ggae06cd8869fe61d709ad6145ca9f3cd63ab7ec706d80b347433d0063f2a8115784">CY_SYSPM_CHECK_READY</a>:</div><div class="line">        {</div><div class="line">            <span class="keywordflow">if</span> (!<a class="code" href="group__group__scb__spi__general__functions.html#ga4241f6166816159f7365220834a5e0d0">Cy_SCB_SPI_IsBusBusy</a>(hwBase))</div><div class="line">            {</div><div class="line">                <span class="comment">/* Process the &quot;check ready&quot; condition */</span></div><div class="line">                retVal = <a class="code" href="group__group__syspm__data__enumerates.html#gga601b1cb722cb091133caf33d8ab235caaf00d22f1ee891a8a56f8bbf58132e775">CY_SYSPM_SUCCESS</a>;</div><div class="line">            }</div><div class="line">        </div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__syspm__data__enumerates.html#ggae06cd8869fe61d709ad6145ca9f3cd63a7d302375276b3b5f250a8208c999b558">CY_SYSPM_BEFORE_TRANSITION</a>:</div><div class="line">        {</div><div class="line">            <span class="comment">/* Switch - Turn off SCB SPI */</span></div><div class="line">            retVal = <a class="code" href="group__group__syspm__data__enumerates.html#gga601b1cb722cb091133caf33d8ab235caaf00d22f1ee891a8a56f8bbf58132e775">CY_SYSPM_SUCCESS</a>;</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line">        </div><div class="line">        </div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__syspm__data__enumerates.html#ggae06cd8869fe61d709ad6145ca9f3cd63aafd1db1f7f86ac7bbd18d59b78af5693">CY_SYSPM_AFTER_TRANSITION</a>:</div><div class="line">        {</div><div class="line">            <span class="comment">/* Switch - Turn on SCB SPI */</span></div><div class="line">            retVal = <a class="code" href="group__group__syspm__data__enumerates.html#gga601b1cb722cb091133caf33d8ab235caaf00d22f1ee891a8a56f8bbf58132e775">CY_SYSPM_SUCCESS</a>;</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__syspm__data__enumerates.html#ggae06cd8869fe61d709ad6145ca9f3cd63a96acf2d0ae5537798228d5fba0fecd17">CY_SYSPM_CHECK_FAIL</a>:</div><div class="line">        {</div><div class="line">            <span class="comment">/* Revert changes made in CY_SYSPM_CHECK_READY switch case (if any) */</span></div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="keywordflow">default</span>:</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">    }</div><div class="line">    </div><div class="line">    <span class="keywordflow">return</span> (retVal);</div><div class="line">}</div></div><!-- fragment --><div class="fragment"><div class="line">    <span class="comment">/* Register myDeepSleep1 */</span></div><div class="line">    <span class="keywordflow">if</span> (<span class="keyword">true</span> != <a class="code" href="group__group__syspm__functions__callback.html#ga0d58b00c8dc764a6371590f70e2f73c7">Cy_SysPm_RegisterCallback</a>(&amp;myDeepSleep1))</div><div class="line">    {</div><div class="line">        <span class="comment">/* Insert error handling */</span></div><div class="line">    }</div><div class="line">    </div><div class="line">    <span class="comment">/* Register myDeepSleep2 */</span></div><div class="line">    <span class="keywordflow">if</span> (<span class="keyword">true</span> != <a class="code" href="group__group__syspm__functions__callback.html#ga0d58b00c8dc764a6371590f70e2f73c7">Cy_SysPm_RegisterCallback</a>(&amp;myDeepSleep2))</div><div class="line">    {</div><div class="line">        <span class="comment">/* Insert error handling */</span></div><div class="line">    }</div><div class="line">    </div><div class="line">    <span class="comment">/* Register myDeepSleep3 */</span></div><div class="line">    <span class="keywordflow">if</span> (<span class="keyword">true</span> != <a class="code" href="group__group__syspm__functions__callback.html#ga0d58b00c8dc764a6371590f70e2f73c7">Cy_SysPm_RegisterCallback</a>(&amp;myDeepSleep3))</div><div class="line">    {</div><div class="line">        <span class="comment">/* Insert error handling */</span></div><div class="line">    }</div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="gab7b9b923fceff2f37a6b8288253b0e82"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab7b9b923fceff2f37a6b8288253b0e82">&#9670;&nbsp;</a></span>Cy_SysPm_UnregisterCallback()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Cy_SysPm_UnregisterCallback </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structcy__stc__syspm__callback__t.html">cy_stc_syspm_callback_t</a> const *&#160;</td>
          <td class="paramname"><em>handler</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function unregisters a callback. </p>
<p>The registered callback can be unregistered and the function returns true. Otherwise, false is returned.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">handler</td><td>The item that should be unregistered. See <a class="el" href="structcy__stc__syspm__callback__t.html">cy_stc_syspm_callback_t</a>.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>True if callback was unregistered.</li>
<li>False if it was not unregistered or no callbacks are registered.</li>
</ul>
</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line">    <span class="comment">/* Scenario: There is a need to unregister a previously registered callback */</span></div><div class="line">    <span class="keywordflow">if</span> (<span class="keyword">true</span> != <a class="code" href="group__group__syspm__functions__callback.html#gab7b9b923fceff2f37a6b8288253b0e82">Cy_SysPm_UnregisterCallback</a>(&amp;myDeepSleep2))</div><div class="line">    {</div><div class="line">        <span class="comment">/* Insert error handler */</span></div><div class="line">    }</div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="ga95462119281ba8dec6b313f85dd752b0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga95462119281ba8dec6b313f85dd752b0">&#9670;&nbsp;</a></span>Cy_SysPm_ExecuteCallback()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__syspm__data__enumerates.html#ga601b1cb722cb091133caf33d8ab235ca">cy_en_syspm_status_t</a> Cy_SysPm_ExecuteCallback </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__syspm__data__enumerates.html#ga8c2960c0164ead1cfa86e7d6846b6ff0">cy_en_syspm_callback_type_t</a>&#160;</td>
          <td class="paramname"><em>type</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__syspm__data__enumerates.html#gae06cd8869fe61d709ad6145ca9f3cd63">cy_en_syspm_callback_mode_t</a>&#160;</td>
          <td class="paramname"><em>mode</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The function executes all registered callbacks with provided type and mode. </p>
<dl class="section note"><dt>Note</dt><dd>This low-level function is being used by <a class="el" href="group__group__syspm__functions__power.html#gab09936e85606de476a0c379f9548603f">Cy_SysPm_CpuEnterSleep</a>, <a class="el" href="group__group__syspm__functions__power.html#ga5150c28fe4d2626720c1fbf74b3111ca">Cy_SysPm_CpuEnterDeepSleep</a>, <a class="el" href="group__group__syspm__functions__power.html#gae97647a28c370674ba57d451d21d1c51">Cy_SysPm_SystemEnterHibernate</a>, <a class="el" href="group__group__syspm__functions__power.html#gaca7c8f1ab6d555530a68978269198836">Cy_SysPm_SystemEnterUlp</a> and <a class="el" href="group__group__syspm__functions__power.html#ga72531fcca015df727a163b510639a334">Cy_SysPm_SystemEnterLp</a> API functions. However, it might be also useful as an independent API function in some custom applications.</dd>
<dd>
The registered callbacks will be executed in order based on <a class="el" href="group__group__syspm__data__enumerates.html#ga8c2960c0164ead1cfa86e7d6846b6ff0">cy_en_syspm_callback_type_t</a> value. There are two possible callback execution orders:<ul>
<li>From first registered to last registered. This order applies to callbacks with mode CY_SYSPM_CHECK_READY and CY_SYSPM_BEFORE_TRANSITION.</li>
<li>Backward flow execution:<ul>
<li>From last registered to the first registered. This order applies to callbacks with mode CY_SYSPM_AFTER_TRANSITION.</li>
<li>From last called to the first registered callback. This order applies to callbacks with mode CY_SYSPM_CHECK_FAIL. Note that, the last called callback function that generated the CY_SYSPM_CHECK_FAIL is skipped when mode CY_SYSPM_CHECK_FAIL. This is because the callback that returns CY_SYSPM_FAIL already knows that it failed and will not take any action that requires correction.</li>
</ul>
</li>
</ul>
</dd></dl>
<p>If no callbacks are registered, returns CY_SYSPM_SUCCESS.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">type</td><td>The callback type. See <a class="el" href="group__group__syspm__data__enumerates.html#ga8c2960c0164ead1cfa86e7d6846b6ff0">cy_en_syspm_callback_type_t</a>.</td></tr>
    <tr><td class="paramname">mode</td><td>The callback mode. See <a class="el" href="group__group__syspm__data__enumerates.html#gae06cd8869fe61d709ad6145ca9f3cd63">cy_en_syspm_callback_mode_t</a>.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>CY_SYSPM_SUCCESS if callback successfully completed or nor callbacks registered.</li>
<li>CY_SYSPM_FAIL one of the executed callback(s) returned fail.</li>
</ul>
</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line">    <span class="comment">/* Scenario: There is a need to execute all the registered callbacks for </span></div><div class="line"><span class="comment">    *  CPU Sleep mode and Check Ready condition</span></div><div class="line"><span class="comment">    */</span></div><div class="line">    <span class="keywordflow">if</span> (<a class="code" href="group__group__syspm__data__enumerates.html#gga601b1cb722cb091133caf33d8ab235caaf00d22f1ee891a8a56f8bbf58132e775">CY_SYSPM_SUCCESS</a> != <a class="code" href="group__group__syspm__functions__callback.html#ga95462119281ba8dec6b313f85dd752b0">Cy_SysPm_ExecuteCallback</a>(<a class="code" href="group__group__syspm__data__enumerates.html#gga8c2960c0164ead1cfa86e7d6846b6ff0ac8d781c074f372d0b201da4e040a4768">CY_SYSPM_SLEEP</a>, <a class="code" href="group__group__syspm__data__enumerates.html#ggae06cd8869fe61d709ad6145ca9f3cd63ab7ec706d80b347433d0063f2a8115784">CY_SYSPM_CHECK_READY</a>))</div><div class="line">    {</div><div class="line">        <span class="comment">/* Insert error handling */</span></div><div class="line">    }</div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="gaa6983aaa09683543722f57bbe76b9695"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa6983aaa09683543722f57bbe76b9695">&#9670;&nbsp;</a></span>Cy_SysPm_GetFailedCallback()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structcy__stc__syspm__callback__t.html">cy_stc_syspm_callback_t</a>* Cy_SysPm_GetFailedCallback </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__syspm__data__enumerates.html#ga8c2960c0164ead1cfa86e7d6846b6ff0">cy_en_syspm_callback_type_t</a>&#160;</td>
          <td class="paramname"><em>type</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reads the result of the callback execution after the power mode functions execution. </p>
<p>This function reads the value of the pointer that stores the result of callback execution. It takes power mode as the parameter and returns the address of the callback configuration structure in the case of failure or NULL in the case of success. This address of the failed callback allows finding the callback that blocks entering power mode.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">type</td><td>Power mode for which a callback execution result is required.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>The address of the callback configuration structure if the callback handler function failed.</li>
<li>NULL if the callback skipped or executed successfully.</li>
</ul>
</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line">    <span class="comment">/* Scenario: There is a need to put the CPU into Deep Sleep mode, and in the case</span></div><div class="line"><span class="comment">    *  of failure - to trace failed callback</span></div><div class="line"><span class="comment">    */</span></div><div class="line"></div><div class="line">    <span class="comment">/* Prepare the system for Deep Sleep power mode */</span></div><div class="line">    <span class="keywordflow">if</span>(<a class="code" href="group__group__syspm__data__enumerates.html#gga601b1cb722cb091133caf33d8ab235caaf00d22f1ee891a8a56f8bbf58132e775">CY_SYSPM_SUCCESS</a> != <a class="code" href="group__group__syspm__functions__power.html#ga5150c28fe4d2626720c1fbf74b3111ca">Cy_SysPm_CpuEnterDeepSleep</a>(<a class="code" href="group__group__syspm__data__enumerates.html#ggaae6a9f528630a2d69bb70b3bced1f0acadf47e50b6700c08b6f9e7e70bb525541">CY_SYSPM_WAIT_FOR_INTERRUPT</a>))</div><div class="line">    {</div><div class="line">        <span class="comment">/* CPU did not enter Deep Sleep mode because one of executed callback </span></div><div class="line"><span class="comment">        *  returned a &quot;fail&quot; status</span></div><div class="line"><span class="comment">        */</span></div><div class="line"></div><div class="line">        <span class="comment">/* Call Cy_SysPm_GetFailedCallback to get the address of the failed callback */</span></div><div class="line">        <a class="code" href="structcy__stc__syspm__callback__t.html">cy_stc_syspm_callback_t</a>* failedCallbackPtr = <a class="code" href="group__group__syspm__functions__callback.html#gaa6983aaa09683543722f57bbe76b9695">Cy_SysPm_GetFailedCallback</a>(<a class="code" href="group__group__syspm__data__enumerates.html#gga8c2960c0164ead1cfa86e7d6846b6ff0abc51d74deff0ceea4304b01b2d57bd9d">CY_SYSPM_DEEPSLEEP</a>);</div><div class="line"></div><div class="line">        <span class="comment">/* Find out which callback failed */</span></div><div class="line">        <span class="keywordflow">if</span>(failedCallbackPtr == (&amp;myDeepSleep1))</div><div class="line">        {</div><div class="line">            <span class="comment">/* myDeepSleep1 callback failed */</span></div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span>(failedCallbackPtr == (&amp;myDeepSleep2))</div><div class="line">        {</div><div class="line">            <span class="comment">/* myDeepSleep2 callback failed */</span></div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span>(failedCallbackPtr == (&amp;myDeepSleep3))</div><div class="line">        {</div><div class="line">            <span class="comment">/* myDeepSleep3 callback failed */</span></div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> </div><div class="line">        {</div><div class="line">            <span class="comment">/* In this case, the address of the failed callback was not compared</span></div><div class="line"><span class="comment">            *  with the address returned by Cy_SysPm_GetFailedCallback</span></div><div class="line"><span class="comment">            */</span></div><div class="line">        }</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        <span class="comment">/* If the program has reached here, the core is just woken up</span></div><div class="line"><span class="comment">         * from the CPU Deep Sleep mode</span></div><div class="line"><span class="comment">         */</span></div><div class="line">    }</div></div><!-- fragment --></dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>MTB CAT1 Peripheral driver library</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
